package com.sinkingsquare.web.core;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

public abstract class AbstractMvcController extends AbstractBaseController {

	@SuppressWarnings("unchecked")
	public final ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Map map = getModel(request, response);
		if(map == null)
			return null;
		String view = getView(request, response);
		return new ModelAndView(view, map);
	}

	public abstract String getView(HttpServletRequest request,
			HttpServletResponse response) throws Exception;

	@SuppressWarnings("unchecked")
	public abstract Map getModel(HttpServletRequest request,
			HttpServletResponse response) throws Exception;

}
